package com.itheima.service.db.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.domain.db.Deblocking;
import com.itheima.mapper.DeblockingMapper;
import com.itheima.service.db.DeblockingService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class DeblockingServiceImpl implements DeblockingService {

    @Autowired
    private DeblockingMapper deblockingMapper;
    /*
     *  用户解冻
     *
     * @param deblocking 解冻类
     * @author
     * @date
     * @return java.lang.Integer
     */

    @Override
    public Integer saveuserDeblocking(Deblocking deblocking) {
       return  deblockingMapper.insert(deblocking);
    }

    /*
     *
     * 查询解冻数据
     *
     * @param id 登录用户Id
     * @author
     * @date
     * @return com.itheima.domain.db.Deblocking
     */

    @Override
    public Deblocking findByUserId(Long id) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("user_id",id);
        return  deblockingMapper.selectOne(queryWrapper);
    }


    /*
     *
     *
     * @param id    用户Id
     * @author
     * @date
     * @return void
     */

    @Override
    public void deleteByUserId(Long id) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("user_id",id);
         deblockingMapper.delete(queryWrapper);

    }
}
